export const backStore = {
  callback: [],
  on(context, fn) {
    this.callback.unshift({
      id: context._uid,
      fn: fn
    })
  },
  off(context) {
    let index = this.callback.findIndex(v => v.id === context._uid)
    if (index === -1) return
    this.callback.splice(index, 1)
  },
  emit() {
    let first = this.callback[0]
    if (!first) return
    first.fn()
  }
}

window.backStore = backStore
